<?php

declare(strict_types=1);

namespace App\Exchange\Model;

use App\Fastapp\Model\Currency;
use Hyperf\Database\Model\Relations\HasOne;
use Mine\MineModel;

/**
 * @property int $id 主键
 * @property int $legal_id 法币id
 * @property int $currency_id 币种id
 * @property int $status 启用0否1是
 * @property int $is_show 显示0否1是
 * @property int $sort 排序
 * @property string $face_value 面值
 * @property string $fee_open 手续费开仓或买单
 * @property string $fee_close 手续费平仓
 * @property string $min_sell 最低卖单
 * @property string $max_sell 最高卖单
 * @property string $min_amount 最低挂单数量
 * @property string $max_amount 最高挂单数量
 * @property string $keep_rate 保证金维持率
 * @property int $max_lever 最高杠杆倍数
 * @property int $funds_interval 资金费率结算周期，小时
 * @property int $slippage_type 类型0无1百分比2固定点
 * @property string $slippage_type_val 滑点
 */
class ExchangePairList extends MineModel
{
    public bool $timestamps = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'exchange_pair_list';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'legal_id', 'currency_id', 'status', 'is_show', 'sort', 'face_value', 'fee_open', 'fee_close', 'min_sell', 'max_sell', 'min_amount', 'max_amount', 'keep_rate', 'max_lever', 'funds_interval', 'slippage_type', 'slippage_type_val'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'legal_id' => 'integer', 'currency_id' => 'integer', 'status' => 'integer', 'is_show' => 'integer', 'sort' => 'integer', 'face_value' => 'decimal:2', 'fee_open' => 'decimal:2', 'fee_close' => 'decimal:2', 'min_sell' => 'decimal:2', 'max_sell' => 'decimal:2', 'min_amount' => 'decimal:2', 'max_amount' => 'decimal:2', 'keep_rate' => 'decimal:2', 'max_lever' => 'integer', 'funds_interval' => 'integer', 'slippage_type' => 'integer', 'slippage_type_val' => 'decimal:2'];

    public function currency(): HasOne
    {
        return $this->hasOne(Currency::class, 'id', 'currency_id');
    }
}
